package com.example.wan1.view.system.question;

import com.example.wan1.data.BaseObserver;
import com.example.wan1.data.RetrofitUtil;
import com.example.wan1.data.RxSchedulers;
import com.example.wan1.model.ArticleBean;
import com.example.wan1.model.common.CommonResList;

import javax.inject.Inject;

/***
 * 创建时间：2020/7/10 20:58
 * 创建人：10850
 * 功能描述：
 */
public class QuestionPresenter implements
        QuestionContract.Presenter {
    @Inject
    QuestionContract.View mView;

    @Inject
    public QuestionPresenter() {

    }

    @Override
    public void getQuestionList(int page) {
        RetrofitUtil.getInstance().getQuestion(page)
                .compose(RxSchedulers.observableIO2Main())
                .subscribe(new BaseObserver<CommonResList<ArticleBean>>() {
                    @Override
                    public void onSuccess(CommonResList<ArticleBean> result) {
                        mView.onSuccess(result);
                    }

                    @Override
                    public void onFailure(Throwable e, String errorMsg) {
                        mView.onFailure(e.getMessage());
                    }
                });
    }
}
